<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //1. 字面量模式 
        const lcq = {
            name: "李长青",
            age: 22,
            say: function () {
                console.log('您好！')
            }
        }
        //创建一个空对象
        const obj1 = {}
        const obj2 = new Object()
        //2. 工厂模式
        function createStu(name, age) {
            let obj = {
                name: name,
                age: age,
                say: function () {
                    console.log(`您好！,我叫${name}`)
                }
            }
            return obj
        }
        const stu1 = createStu('唐文清',22)
        const stu2 = createStu("温建鑫",20)

        //构造函数
        function Stu(name, age){
            //this指向创建的实例对象
            this.name = name
            this.age = age
            this.say = function(){
                console.log(`您好！我是${this.name}`)
            }
        }

        const zz = new Stu('周周',20)
        const ll = new Stu('刘磊',19)
        //原型
        function Stu1(name, age){
            //this指向创建的实例对象
            this.name = name
            this.age = age
        }
        const zz1 = new Stu1('周周',20)
        const ll1 = new Stu1('刘磊',19)
        Stu1.prototype.say = function(){
            console.log(`你好，我是${this.name}`)
        }
        Stu1.prototype.className = "w2002"

        const key = "name"
        ll1.hp = 200
        ll1.hp = 220
        delete ll1.hp
        
        
        
    </script>
</body>

</html>